Optimal. Leaf size=61 \[ \frac {2 a^2 \tan ^{-1}\left (\frac {a \tan \left (\frac {x}{2}\right )+b}{\sqrt {a^2-b^2}}\right )}{b^2 \sqrt {a^2-b^2}}-\frac {a x}{b^2}-\frac {\cos (x)}{b} \]
[Out]
________________________________________________________________________________________
Rubi [A] time = 0.10, antiderivative size = 61, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 6, integrand size = 13, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.462, Rules used = {2746, 12, 2735, 2660, 618, 204} \[ \frac {2 a^2 \tan ^{-1}\left (\frac {a \tan \left (\frac {x}{2}\right )+b}{\sqrt {a^2-b^2}}\right )}{b^2 \sqrt {a^2-b^2}}-\frac {a x}{b^2}-\frac {\cos (x)}{b} \]
Antiderivative was successfully verified.
[In]
[Out]
Rule 12
Rule 204
Rule 618
Rule 2660
Rule 2735
Rule 2746
Rubi steps
\begin {align*} \int \frac {\sin ^2(x)}{a+b \sin (x)} \, dx &=-\frac {\cos (x)}{b}-\frac {\int \frac {a \sin (x)}{a+b \sin (x)} \, dx}{b}\\ &=-\frac {\cos (x)}{b}-\frac {a \int \frac {\sin (x)}{a+b \sin (x)} \, dx}{b}\\ &=-\frac {a x}{b^2}-\frac {\cos (x)}{b}+\frac {a^2 \int \frac {1}{a+b \sin (x)} \, dx}{b^2}\\ &=-\frac {a x}{b^2}-\frac {\cos (x)}{b}+\frac {\left (2 a^2\right ) \operatorname {Subst}\left (\int \frac {1}{a+2 b x+a x^2} \, dx,x,\tan \left (\frac {x}{2}\right )\right )}{b^2}\\ &=-\frac {a x}{b^2}-\frac {\cos (x)}{b}-\frac {\left (4 a^2\right ) \operatorname {Subst}\left (\int \frac {1}{-4 \left (a^2-b^2\right )-x^2} \, dx,x,2 b+2 a \tan \left (\frac {x}{2}\right )\right )}{b^2}\\ &=-\frac {a x}{b^2}+\frac {2 a^2 \tan ^{-1}\left (\frac {b+a \tan \left (\frac {x}{2}\right )}{\sqrt {a^2-b^2}}\right )}{b^2 \sqrt {a^2-b^2}}-\frac {\cos (x)}{b}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A] time = 0.09, size = 56, normalized size = 0.92 \[ -\frac {-\frac {2 a^2 \tan ^{-1}\left (\frac {a \tan \left (\frac {x}{2}\right )+b}{\sqrt {a^2-b^2}}\right )}{\sqrt {a^2-b^2}}+a x+b \cos (x)}{b^2} \]
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
fricas [A] time = 0.50, size = 231, normalized size = 3.79 \[ \left [-\frac {\sqrt {-a^{2} + b^{2}} a^{2} \log \left (\frac {{\left (2 \, a^{2} - b^{2}\right )} \cos \relax (x)^{2} - 2 \, a b \sin \relax (x) - a^{2} - b^{2} + 2 \, {\left (a \cos \relax (x) \sin \relax (x) + b \cos \relax (x)\right )} \sqrt {-a^{2} + b^{2}}}{b^{2} \cos \relax (x)^{2} - 2 \, a b \sin \relax (x) - a^{2} - b^{2}}\right ) + 2 \, {\left (a^{3} - a b^{2}\right )} x + 2 \, {\left (a^{2} b - b^{3}\right )} \cos \relax (x)}{2 \, {\left (a^{2} b^{2} - b^{4}\right )}}, -\frac {\sqrt {a^{2} - b^{2}} a^{2} \arctan \left (-\frac {a \sin \relax (x) + b}{\sqrt {a^{2} - b^{2}} \cos \relax (x)}\right ) + {\left (a^{3} - a b^{2}\right )} x + {\left (a^{2} b - b^{3}\right )} \cos \relax (x)}{a^{2} b^{2} - b^{4}}\right ] \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
giac [A] time = 0.36, size = 77, normalized size = 1.26 \[ \frac {2 \, {\left (\pi \left \lfloor \frac {x}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\relax (a) + \arctan \left (\frac {a \tan \left (\frac {1}{2} \, x\right ) + b}{\sqrt {a^{2} - b^{2}}}\right )\right )} a^{2}}{\sqrt {a^{2} - b^{2}} b^{2}} - \frac {a x}{b^{2}} - \frac {2}{{\left (\tan \left (\frac {1}{2} \, x\right )^{2} + 1\right )} b} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
maple [A] time = 0.07, size = 72, normalized size = 1.18 \[ -\frac {2}{b \left (\tan ^{2}\left (\frac {x}{2}\right )+1\right )}-\frac {2 \arctan \left (\tan \left (\frac {x}{2}\right )\right ) a}{b^{2}}+\frac {2 a^{2} \arctan \left (\frac {2 a \tan \left (\frac {x}{2}\right )+2 b}{2 \sqrt {a^{2}-b^{2}}}\right )}{b^{2} \sqrt {a^{2}-b^{2}}} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
maxima [F(-2)] time = 0.00, size = 0, normalized size = 0.00 \[ \text {Exception raised: ValueError} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
mupad [B] time = 6.91, size = 623, normalized size = 10.21 \[ -\frac {2}{b\,\left ({\mathrm {tan}\left (\frac {x}{2}\right )}^2+1\right )}-\frac {a\,x}{b^2}-\frac {a^2\,\mathrm {atan}\left (\frac {\frac {a^2\,\left (\frac {32\,a^4}{b}-\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (2\,a^5\,b-2\,a^3\,b^3\right )}{b^3}+\frac {a^2\,\left (32\,a^2\,b^2+64\,a^3\,b\,\mathrm {tan}\left (\frac {x}{2}\right )+\frac {a^2\,\left (32\,a^2\,b^3+\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (3\,a\,b^7-2\,a^3\,b^5\right )}{b^3}\right )}{b^2\,\sqrt {b^2-a^2}}\right )}{b^2\,\sqrt {b^2-a^2}}\right )\,1{}\mathrm {i}}{b^2\,\sqrt {b^2-a^2}}-\frac {a^2\,\left (\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (2\,a^5\,b-2\,a^3\,b^3\right )}{b^3}-\frac {32\,a^4}{b}+\frac {a^2\,\left (32\,a^2\,b^2+64\,a^3\,b\,\mathrm {tan}\left (\frac {x}{2}\right )-\frac {a^2\,\left (32\,a^2\,b^3+\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (3\,a\,b^7-2\,a^3\,b^5\right )}{b^3}\right )}{b^2\,\sqrt {b^2-a^2}}\right )}{b^2\,\sqrt {b^2-a^2}}\right )\,1{}\mathrm {i}}{b^2\,\sqrt {b^2-a^2}}}{\frac {128\,a^5\,\mathrm {tan}\left (\frac {x}{2}\right )}{b^3}+\frac {a^2\,\left (\frac {32\,a^4}{b}-\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (2\,a^5\,b-2\,a^3\,b^3\right )}{b^3}+\frac {a^2\,\left (32\,a^2\,b^2+64\,a^3\,b\,\mathrm {tan}\left (\frac {x}{2}\right )+\frac {a^2\,\left (32\,a^2\,b^3+\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (3\,a\,b^7-2\,a^3\,b^5\right )}{b^3}\right )}{b^2\,\sqrt {b^2-a^2}}\right )}{b^2\,\sqrt {b^2-a^2}}\right )}{b^2\,\sqrt {b^2-a^2}}+\frac {a^2\,\left (\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (2\,a^5\,b-2\,a^3\,b^3\right )}{b^3}-\frac {32\,a^4}{b}+\frac {a^2\,\left (32\,a^2\,b^2+64\,a^3\,b\,\mathrm {tan}\left (\frac {x}{2}\right )-\frac {a^2\,\left (32\,a^2\,b^3+\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (3\,a\,b^7-2\,a^3\,b^5\right )}{b^3}\right )}{b^2\,\sqrt {b^2-a^2}}\right )}{b^2\,\sqrt {b^2-a^2}}\right )}{b^2\,\sqrt {b^2-a^2}}}\right )\,2{}\mathrm {i}}{b^2\,\sqrt {b^2-a^2}} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
sympy [F(-1)] time = 0.00, size = 0, normalized size = 0.00 \[ \text {Timed out} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________